<template>
  <div class='wrap'>

    <el-tabs v-model="activePanel" type="card" @tab-click="handleClick" class='tabPanel'>
      <el-tab-pane label="今日手术" name="pending">
        <div class="app-button-container">
            <el-button type="primary" @click="dialogLeftTop1_1_show()">手术报到</el-button>
            <!-- <el-button type="primary" @click= "propagandaAndEducation"><a target='_blank' href="src/yimiviews/pages/infomation.html">进度提醒</a></el-button> -->
            <!-- <el-button type="primary" @click= "dialogLeftTop1_3_show">离院确认</el-button> -->
            <el-button type="primary" @click= "dialogLeftTop1_4_show">退出日间</el-button>
            <el-select clearable style="width: 120px" class="filter-item" v-model="oneOperate" placeholder="更多操作" :disabled="!disabled" @change = 'handleDownload'>
              <el-option v-for="item in patientManageConst.moreOperate" :key="item.key" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
        </div>

        <div class="filter-container">
          <div class= 'filterBox'>
            <div class='leftPart filterPart'>
              <el-checkbox class="filter-item todayCheckBox" style="margin-left:15px;" v-model="checkValue"  @change="todayAppointment">今日预约</el-checkbox>
            </div>
            <div class='rightPart filterPart'>
              <el-select clearable style="width: 120px" class="filter-item" v-model="filter1.type">
                <el-option label="患者姓名" value="type0"></el-option>
                <el-option label="手机号后四位" value="type1"></el-option>
                <el-option label="就诊卡号" value="type2"></el-option>
              </el-select>
              <el-input style="width: 220px;" class="filter-item" placeholder="请输入搜索条件" v-model="filter1.keyWord">
              </el-input>
              <el-select clearable style="width: 196px" class="filter-item" v-model="filter1.surgeryPath" placeholder="请选择手术路径">
                <el-option label="预约申请" value="0"></el-option>
                <el-option label="预约确认" value="1"></el-option>
                <el-option label="麻醉评估" value="2"></el-option>
                <el-option label="中心核对" value="3"></el-option>
                <el-option label="入院前宣教" value="4"></el-option>
                <el-option label="术前确认" value="5"></el-option>
                <el-option label="手术报到" value="6"></el-option>
                <el-option label="出院评估" value="7"></el-option>
                <el-option label="完成" value="8"></el-option>
              </el-select>
              <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
            </div>
          </div>
        </div>

        <complex-table
          :hasOperate = false
          :list = 'tableList1'
          :totalList = 'totalList1'
          :theadList = "patientManageConst.theadList1"
          :operationButtons = 'patientManageConst.operationpendingButtons'
          @initListQuery = 'initListQuery'
          @getListByPagination = 'getListByPagination'
          @getSelectArr = 'getSelectArr'>
          </complex-table>

      </el-tab-pane>

      <!-- <el-tab-pane label="待离院病人" name="outpatient">
        <div class="app-button-container">
          <el-button type="primary" @click = "dialogLeftTop2_1_show">离院确认</el-button>
          <el-button type="primary" @click = "dialogLeftTop2_2_show">手术取消</el-button>
          <el-select clearable style="width: 120px" class="filter-item" v-model="oneOperate2" placeholder="更多操作" :disabled="!disabled2" @change = 'handleDownload'>
            <el-option v-for="item in patientManageConst.moreOperate" :key="item.key" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="filter-container">
          <div class= 'filterBox'>
            <div class='leftPart filterPart'></div>
            <div class='rightPart filterPart'>
              <el-input style="width: 220px;" class="filter-item" placeholder="输入患者姓名/手机号后四位" v-model="filter.nameTel">
              </el-input>
              <el-input style="width: 220px;" class="filter-item" placeholder="就诊卡号/身份证号" v-model="filter.cardNo">
              </el-input>
              <el-select clearable style="width: 120px" class="filter-item" v-model="filter.origin" placeholder="预约来源">
                <el-option v-for="item in filter.originOptions" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
              <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
            </div>
          </div>
        </div>
        <complex-table :list = 'tableList2' :theadList = "patientManageConst.theadList2" :hasOperate = false @getSelectArr ='getSelectArr2'></complex-table>
      </el-tab-pane> -->

      <el-tab-pane label="历史病人" name="historyPatient">
        <div class="app-button-container">
            <el-button type="primary" @click="dialogLeftTop3_1_show">撤销离院</el-button>
            <el-select clearable style="width: 120px" class="filter-item" v-model="oneOperate3" placeholder="更多操作" :disabled="!disabled3" @change = 'handleDownload'>
              <el-option v-for="item in patientManageConst.moreOperate" :key="item.key" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
        </div>
        <div class="filter-container">
          <div class= 'filterBox'>
            <div class='leftPart filterPart'></div>
            <div class='rightPart filterPart'>
              <el-select clearable style="width: 120px" class="filter-item" v-model="filter2.type">
                <el-option label="患者姓名" value="type0"></el-option>
                <el-option label="手机号后四位" value="type1"></el-option>
                <el-option label="就诊卡号" value="type2"></el-option>
              </el-select>
              <el-input style="width: 220px;" class="filter-item" placeholder="请输入搜索条件" v-model="filter2.keyWord">
              </el-input>
              <el-select clearable style="width: 196px" class="filter-item" v-model="filter2.surgeryPath" placeholder="请选择手术路径">
                <el-option label="预约申请" value="0"></el-option>
                <el-option label="预约确认" value="1"></el-option>
                <el-option label="麻醉评估" value="2"></el-option>
                <el-option label="中心核对" value="3"></el-option>
                <el-option label="入院前宣教" value="4"></el-option>
                <el-option label="术前确认" value="5"></el-option>
                <el-option label="手术报到" value="6"></el-option>
                <el-option label="出院评估" value="7"></el-option>
                <el-option label="完成" value="8"></el-option>
              </el-select>
              <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter1">搜索</el-button>
            </div>
          </div>
        </div>
        <complex-table
          :list = 'tableList3'
          :totalList = 'totalList2'
          :theadList = "patientManageConst.theadList3"
          :hasOperate = false
          @initListQuery = 'initListQuery'
          @getListByPagination = 'getHisListByPagination'
          @getSelectArr = 'getSelectArr3'>
        </complex-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 1-1 手术报到 -->

  <el-dialog title='手术报到' :visible.sync="dialogLeftTop1_1" class='dialogLeftTop1_1'>
    <el-steps :active="dialogLeftTop1_1_step_active" finish-status="success" name= '"dialogLeftTop1_1_step_active"'>
        <el-step title="信息确认"></el-step>
        <el-step title="术前宣教"></el-step>
        <el-step title="报到成功"></el-step>
    </el-steps>
    <el-tabs v-model="dialogLeftTop1_1_tab_active">
      <el-tab-pane name ='0'>
        <el-row :gutter="12">
          <el-col :span="8">
              患者姓名： <span>{{dialogLeftTop1_1_tab1_data.patientName}}</span>
          </el-col>
          <el-col :span="8">
              性别： <span>{{dialogLeftTop1_1_tab1_data.sex}}</span>
          </el-col>
          <el-col :span="8">
              年龄：<span>{{dialogLeftTop1_1_tab1_data.age}}</span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
              手术名称： <span>{{dialogLeftTop1_1_tab1_data.operationName}}</span>
          </el-col>
          <el-col :span="12">
              主刀医生： <span>{{dialogLeftTop1_1_tab1_data.operateDoctor}}</span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
              手术时间： <span>{{dialogLeftTop1_1_tab1_data.scheduleTime}}</span>
          </el-col>
          <el-col :span="12">
              手术间： <span>{{dialogLeftTop1_1_tab1_data.operationRoom}}</span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
              拟接收病房： <span>{{dialogLeftTop1_1_tab1_data.wardName}}</span>
          </el-col>
          <el-col :span="12">
              病床号： <span>{{dialogLeftTop1_1_tab1_data.wardBedNo}}</span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
              报到时间： <span>{{dialogLeftTop1_1_tab1_data.rigistration}}</span>
          </el-col>
          <el-col :span="12">
            <el-button type="primary" @click="sendSms">发送短信</el-button>
          </el-col>
        </el-row>
        <div style ='border-top: 1px solid #ddd; padding-top: 20px;'>
          说明
        </div>
        <div>
          <span style ='font-size: 16px;'>核对患者的手术信息</span><br>
          仔细核对患者的姓名、拟手术的名称
        </div>
      </el-tab-pane>
      <el-tab-pane name ='1' class='tab1'>
        <el-row :gutter="20">
          <el-col :span="18" :offset="3">
            <el-form ref="dialogLeftTop1_1_tab2_data" :model="dialogLeftTop1_1_tab2_data" label-width="80px">
              <el-form-item label="宣教类别">
                <el-select v-model="dialogLeftTop1_1_tab2_data.PAEType" placeholder="请选择宣教类别">
                  <el-option label="术前宣教" value="1"></el-option>
                  <el-option label="术后宣教" value="2"></el-option>
                  <el-option label="出院宣教" value="3"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="宣教内容">
                <el-select v-model="dialogLeftTop1_1_tab2_data.PAEContent" placeholder="请选择宣教内容">
                  <el-option label="术前内容" value="preContent"></el-option>
                  <el-option label="术后内容" value="pendingContent"></el-option>
                  <el-option label="出院内容" value="doneContent"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary">查看详情</el-button>
                <el-button type="primary">发送宣教</el-button>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>
        <div style ='border-top: 1px solid #ddd; padding-top: 20px;'>
          说明
        </div>
        <div>
          <span style ='font-size: 16px;'>给患者发送术前宣教</span><br>
          帮助患者了解手术注意事项及手术风险
        </div>
      </el-tab-pane>
      <el-tab-pane name ='2'>
        <el-row>
          <div style ='margin: 20px 40px;'>
            <i class="el-icon-success" style='color: #67C23A; font-size: 32px; vertical-align: middle; margin-right: 20px;'></i>
            <span>手术报到成功</span>
          </div>
          <el-col>
            <li>患者姓名：{{dialogLeftTop1_1_tab1_data.patientName}}</li>
            <li>性别：{{dialogLeftTop1_1_tab1_data.sex}}</li>
            <li>年龄：{{dialogLeftTop1_1_tab1_data.age}}</li>
            <li>手术名称：{{dialogLeftTop1_1_tab1_data.operationName}}</li>
            <li>主刀医生：{{dialogLeftTop1_1_tab1_data.operateDoctor}}</li>
            <li>手术时间：{{dialogLeftTop1_1_tab1_data.scheduleTime}}</li>
            <li>手术间：{{dialogLeftTop1_1_tab1_data.operationRoom}}</li>
            <li>拟接收病房：{{dialogLeftTop1_1_tab1_data.wardName}}</li>
            <li>病床号：{{dialogLeftTop1_1_tab1_data.wardBedNo}}</li>
            <li>报到时间：{{dialogLeftTop1_1_tab1_data.rigistration}}</li>
          </el-col>
          <div style='color: #409EFF;'>
            <div>信息确认短信------------------------------{{dialogLeftTop1_1_tab3_data.messageSend}}</div>
            <div>术前宣教短信------------------------------{{dialogLeftTop1_1_tab3_data.PEASend}}</div>
          </div>
        </el-row>
        <div style ='border-top: 1px solid #ddd; padding-top: 20px;'>
          说明
        </div>
        <div>
          <span style ='font-size: 16px;'>给患者、主刀医生、麻醉医生 发送手术确认短信</span><br>
          发送短信给相关参入 人员
        </div>
      </el-tab-pane>
    </el-tabs>
    <div slot="footer" class="dialog-footer">
      <el-button @click = 'next()' type="primary">{{nextText}}</el-button>
    </div>
  </el-dialog>

  <!-- 1-3 离院确认 -->
  <el-dialog title="离院确认" :visible.sync="dialogLeftTop1_3">
    <el-form :model="dialogLeftTop1_3_data" :inline="true">
      <el-form-item label="离院类型" :label-width="formLabelWidth">
          <el-select v-model="dialogLeftTop1_3_data.leaveType" placeholder="请选择离院类型" >
              <el-option label="正常离院" value="0"></el-option>
              <el-option label="转住院" value="1"></el-option>
              <el-option label="手术取消" value="2"></el-option>
          </el-select>
      </el-form-item>

      <el-form-item label="离院日期" :label-width="formLabelWidth">
          <el-date-picker type="datetime" placeholder="选择日期时间" v-model="dialogLeftTop1_3_data.expectTime" style="width: 210px;"></el-date-picker>
      </el-form-item>
      <el-form-item label="备注" :label-width="formLabelWidth">
          <el-input type="textarea" :rows="2" v-model="dialogLeftTop1_3_data.remark" auto-complete="off" placeholder="请输入备注" style="width: 210px;"></el-input>
      </el-form-item>
      <el-form-item label="宣教类型" :label-width="formLabelWidth">
        <el-select v-model="dialogLeftTop1_3_data.PAEType" placeholder="请选择宣教类型" >
            <el-option v-for = 'item in PAETypeList' :label="item.label" :value="item.value" :key="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="宣教内容" :label-width="formLabelWidth">
        <el-select v-model="dialogLeftTop1_3_data.PAEContent" placeholder="请选择宣教内容" >
            <el-option v-for = 'item in PAEContentList' :label="item.label" :value="item.value" :key="item.id"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogLeftTop1_3 = false">取 消</el-button>
      <el-button type="primary" @click="dialogLeftTop1_3_submit">确 定</el-button>
    </div>
  </el-dialog>

  <!-- 1-4 手术取消 -->
  <el-dialog title="手术取消" :visible.sync="dialogLeftTop1_4">
    <el-form :model="dialogLeftTop1_4_data" label-width="80px">
      <el-form-item label="取消原因" >
          <el-select v-model="dialogLeftTop1_4_data.cancel" placeholder="请选择取消原因" style="display:block;">
              <el-option v-for="item in CancelTypeList" :label="item.name" :value="item.value" :key='item.value'></el-option>
          </el-select>
      </el-form-item>

      <el-form-item label="备注" >
          <el-input type="textarea" :rows="10" v-model="dialogLeftTop1_4_data.remark" auto-complete="off" placeholder="请输入备注" ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogLeftTop1_4 = false">取 消</el-button>
      <el-button type="primary" @click="dialogLeftTop1_4_submit">确 定</el-button>
    </div>
  </el-dialog>

  <!-- 2-1 离院确认 -->
  <el-dialog title="离院确认" :visible.sync="dialogLeftTop2_1">
    <el-form :model="dialogLeftTop2_1_data" :inline="true">
      <el-form-item label="离院类型" :label-width="formLabelWidth">
          <el-select v-model="dialogLeftTop2_1_data.leaveType" placeholder="请选择离院类型" >
              <el-option label="正常离院" value="0"></el-option>
              <el-option label="转住院" value="1"></el-option>
              <el-option label="手术取消" value="2"></el-option>
          </el-select>
      </el-form-item>

      <el-form-item label="离院日期" :label-width="formLabelWidth">
          <el-date-picker type="datetime" placeholder="选择日期时间" v-model="dialogLeftTop2_1_data.expectTime" style="width: 210px;"></el-date-picker>
      </el-form-item>
      <el-form-item label="备注" :label-width="formLabelWidth">
          <el-input type="textarea" :rows="2" v-model="dialogLeftTop2_1_data.remark" auto-complete="off" placeholder="请输入备注" style="width: 210px;"></el-input>
      </el-form-item>
      <el-form-item label="宣教类型" :label-width="formLabelWidth">
        <el-select v-model="dialogLeftTop2_1_data.PAEType" placeholder="请选择宣教类型" >
            <el-option v-for = 'item in PAETypeList' :label="item.label" :value="item.value" :key="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="宣教内容" :label-width="formLabelWidth">
        <el-select v-model="dialogLeftTop2_1_data.PAEContent" placeholder="请选择宣教内容" >
            <el-option v-for = 'item in PAEContentList' :label="item.label" :value="item.value" :key="item.id"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogLeftTop2_1 = false">取 消</el-button>
      <el-button type="primary" @click="dialogLeftTop2_1_submit">确 定</el-button>
    </div>
  </el-dialog>

  <!-- 2-2 手术取消 -->
  <el-dialog title="手术取消" :visible.sync="dialogLeftTop2_2">
    <el-form :model="dialogLeftTop2_2_data" label-width="80px">
      <el-form-item label="取消原因" >
          <el-select v-model="dialogLeftTop2_2_data.cancel" placeholder="请选择取消原因" style="display:block;">
              <el-option label="放弃手术" value="0"></el-option>
              <el-option label="转住院手术" value="1"></el-option>
              <el-option label="无法联系到病人" value="2"></el-option>
          </el-select>
      </el-form-item>

      <el-form-item label="备注" >
          <el-input type="textarea" :rows="10" v-model="dialogLeftTop2_2_data.remark" auto-complete="off" placeholder="请输入备注" ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogLeftTop2_2 = false">取 消</el-button>
      <el-button type="primary" @click="dialogLeftTop2_2_submit">确 定</el-button>
    </div>
  </el-dialog>

  <!-- 3-1 撤销离院 -->
  <el-dialog title="撤销离院" :visible.sync="dialogLeftTop3_1">
    <el-form :model="dialogLeftTop3_1_data" label-width="80px">
      <el-form-item label="撤消原因" >
          <el-select v-model="dialogLeftTop3_1_data.cancel" placeholder="请选择撤消原因" style="display:block;">
              <el-option v-for="item in revokeReasonList" :label="item.name" :value="item.value" :key='item.value'></el-option>
          </el-select>
      </el-form-item>

      <el-form-item label="备注" >
          <el-input type="textarea" :rows="10" v-model="dialogLeftTop3_1_data.remark" auto-complete="off" placeholder="请输入备注" ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogLeftTop3_1 = false">取 消</el-button>
      <el-button type="primary" @click="dialogLeftTop3_1_submit">确 定</el-button>
    </div>
  </el-dialog>



  </div>
</template>
<script>
  import { parseTime } from '@/utils'
  import complexTable from '@/views/table/complexTable'
  import waves from '@/directive/waves/index.js'
  // import { pending } from '@/api/appointmentManage'
  // import { getPAEType, getPAEContent, sendMessage, sendPAEContent } from '@/api/common'
  import { patientManageConst } from '@/yimiviews/patientManage/columnsConst'
  import { patientList, preoperativeConfirmation, insertConfirmRecord, cancelDaySurgery, getHisPage, revokeOutHospital, sendSms } from '@/api/patientManage/patientManage'
  export default {
    components: { complexTable },
    data() {
      return {
        dialogLeftTop1_1: false,
        dialogLeftTop1_3: false,
        dialogLeftTop1_4: false,
        dialogLeftTop2_1: false,
        dialogLeftTop2_2: false,
        dialogLeftTop3_1: false,
        dialogLeftTop1_1_tab1_data: {
          'patientName': '',
          'sex': '',
          'age': '',
          'operationName': '',
          'doctorName': '',
          'scheduleTime': '',
          'operationRoom': '',
          'wardName': '',
          'wardBedNo': ''
        },
        dialogLeftTop1_1_tab2_data: {
          PAEType: '',
          PAETContent: ''
        },
        dialogLeftTop1_1_tab3_data: {
          'name': '',
          'messageSend': '',
          'PEASend': ''
        },
        dialogLeftTop1_1_step_active: 1,
        dialogLeftTop1_1_tab_active: '0',
        nextText: '下一步',
        dialogLeftTop1_3_data: {
          'leaveType': '',
          'expectTime': '',
          'remark': '',
          'PAEType': '',
          'PAETContent': ''
        },
        dialogLeftTop1_4_data: {
          'cancel': '',
          'remark': ''
        },
        dialogLeftTop2_1_data: {
          'leaveType': '',
          'expectTime': '',
          'remark': '',
          'PAEType': '',
          'PAETContent': ''
        },
        dialogLeftTop2_2_data: {
          'cancel': '',
          'remark': ''
        },
        dialogLeftTop3_1_data: {
          'cancel': '',
          'remark': ''
        },
        PAETypeList: [
          {
            'label': '术前宣教',
            'id': 'paeType0',
            'value': 'paeType0'
          },
          {
            'label': '术中宣教',
            'id': 'paeType1',
            'value': 'paeType1'
          },
          {
            'label': '术后宣教',
            'id': 'paeType2',
            'value': 'paeType2'
          }
        ],
        PAEContentList: [
          {
            'label': '术前注意',
            'id': 'paeContent0',
            'value': 'paeContent0'
          },
          {
            'label': '术中注意',
            'id': 'paeContent1',
            'value': 'paeContent1'
          },
          {
            'label': '术后注意',
            'id': 'paeContent2',
            'value': 'paeContent2'
          }
        ],
        CancelTypeList: [
          {
            'name': '放弃手术',
            'value': '0'
          },
          {
            'name': '转住院手术',
            'value': '1'
          },
          {
            'name': '无法联系到病人',
            'value': '2'
          }
        ],
        revokeReasonList: [
          {
            'name': '放弃手术',
            'value': '0'
          },
          {
            'name': '转住院手术',
            'value': '1'
          },
          {
            'name': '无法联系到病人',
            'value': '2'
          }
        ],
        filter1: {
          type: '',
          keyWord: '',
          surgery: ''
        },
        filter2: {
          type: '',
          keyWord: '',
          surgery: ''
        },
        activePanel: 'pending',
        dialogFormVisible: false,
        form: {
          name: '',
          gender: '1',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        formLabelWidth: '120px',
        filterContainer: {},
        tableList1: [],
        tableList2: [],
        tableList3: [],
        patientManageConst,
        oneOperate: '',
        oneOperate2: '',
        oneOperate3: '',
        selectArr: [],
        selectArr2: [],
        selectArr3: [],
        totalList1: 0,
        listQuery: {
          page: 1,
          limit: 5
        },
        listQuery1: {
          page: 1,
          limit: 5
        },
        totalList2: 1,
        checkValue: false
      }
    },
    mounted() {
      this.getTableList1(this.listQuery)
      this.getHisPatient(this.listQuery1)
    },
    methods: {
      initListQuery(listQuery) {
        this.listQuery.limit = listQuery.limit
        this.listQuery.page = listQuery.page
        this.listQuery1.limit = listQuery.limit
        this.listQuery1.page = listQuery.page
      },
      isSelectOne(selectArr, message) {
        if (!selectArr.length || selectArr.length > 1) {
          this.$message({
            message: message,
            type: 'warning'
          })
          return false
        }
        return true
      },
      dialogLeftTop1_1_show() {
        if (!this.isSelectOne(this.selectArr, '请选择一个报到对象!')) {
          return
        }
        this.dialogLeftTop1_1 = !this.dialogLeftTop1_1
        var data = {
          'id': this.selectArr[0].id
        }
        // 手术报到获取用户手术信息
        preoperativeConfirmation(data).then((res) => {
          console.log(res.data)
          this.dialogLeftTop1_1_tab1_data = res.data.data
        })
      },
      dialogLeftTop1_3_show() {
        if (!this.isSelectOne(this.selectArr, '请选择一个离院对象!')) {
          return
        }
        this.dialogLeftTop1_3 = !this.dialogLeftTop1_3
      },
      dialogLeftTop1_3_submit() {
        this.dialogLeftTop1_3 = !this.dialogLeftTop1_3
      },
      dialogLeftTop1_4_show() {
        if (!this.isSelectOne(this.selectArr, '请选择一个取消手术对象!')) {
          return
        }
        this.dialogLeftTop1_4 = !this.dialogLeftTop1_4
      },
      dialogLeftTop1_4_submit() {
        this.dialogLeftTop1_4 = !this.dialogLeftTop1_4
        var obj = this.CancelTypeList.find((item) => {
          return item.value === this.dialogLeftTop1_4_data.cancel
        })
        // 退出日间
        var data = {
          'appointNo': this.selectArr[0].appointNo,
          'cancelType': this.dialogLeftTop1_4_data.cancel,
          'cancelReason': obj.name,
          'memo': this.dialogLeftTop1_4_data.remark
        }
        cancelDaySurgery(data).then((res) => {
          console.log(res.data)
          this.dialogLeftTop1_4_data.cancel = ''
          this.dialogLeftTop1_4_data.remark = ''
          this.getTableList1(this.listQuery)
          if (this.tableList1.length === 1) {
            this.listQuery.page = (this.filter.listQuery - 1 <= 0 ? 1 : this.listQuery.page - 1)
          }
          this.getTableList1(this.listQuery)
        })
      },
      dialogLeftTop2_1_show() {
        if (!this.isSelectOne(this.selectArr2, '请选择一个离院对象!')) {
          return
        }
        this.dialogLeftTop2_1 = !this.dialogLeftTop2_1
      },
      dialogLeftTop2_1_submit() {
        this.dialogLeftTop2_1 = !this.dialogLeftTop2_1
      },
      dialogLeftTop2_2_show() {
        if (!this.isSelectOne(this.selectArr2, '请选择一个取消手术对象!')) {
          return
        }
        this.dialogLeftTop2_2 = !this.dialogLeftTop2_2
      },
      dialogLeftTop2_2_submit() {
        this.dialogLeftTop2_2 = !this.dialogLeftTop2_2
      },
      dialogLeftTop3_1_show() {
        if (!this.isSelectOne(this.selectArr3, '请选择一个撤销离院对象!')) {
          return
        }
        this.dialogLeftTop3_1 = !this.dialogLeftTop3_1
      },
      dialogLeftTop3_1_submit() {
        this.dialogLeftTop3_1 = !this.dialogLeftTop3_1
        var obj = this.revokeReasonList.find((item) => {
          return item.value === this.dialogLeftTop3_1_data.cancel
        })
        var data = {
          'id': this.selectArr3[0].id,
          'reason': obj.name,
          'remarks': this.dialogLeftTop3_1_data.remark
        }
        revokeOutHospital(data).then((res) => {
          if (res.data.data) {
            this.getHisPatient(this.listQuery1)
          }
        })
      },
      handleFilter() {
        this.getTableList1(this.listQuery)
      },
      handleFilter1() {
        this.getHisPatient(this.listQuery1)
      },
      sendSms() {
        var phone = this.selectArr[0].phone
        console.log(phone)
        var sendTime = this.dialogLeftTop1_1_tab1_data.rigistration
        console.log(sendTime)
        var data = {
          'phone': phone,
          'sendTime': '2018-10-21 10:10:10'
        }
        sendSms(data).then((res) => {
          console.log(res.data.data)
          this.dialogLeftTop1_1_tab3_data.messageSend = res.data.data ? '已发送' : '未发送'
        })
      },
      todayAppointment() {
        if (this.checkValue) {
          this.filter1.today = parseTime(new Date())
        } else {
          this.filter1.today = null
        }
      },
      propagandaAndEducation() {
        if (!this.selectArr.length || this.selectArr.length > 1) {
          this.$message({
            message: '请先选择一个宣教对象！',
            type: 'warning'
          })
          return
        }
      },
      getSelectArr(selectArr) {
        this.selectArr = selectArr
        console.log(selectArr)
      },
      getSelectArr2(selectArr) {
        this.selectArr2 = selectArr
        console.log(this.selectArr2)
      },
      getSelectArr3(selectArr) {
        this.selectArr3 = selectArr
        console.log(this.selectArr3)
      },
      handleClick(tab, event) {
        console.log(tab, event)
      },
      handleDownload() {
        console.log(1212)
        import('@/vendor/Export2Excel').then(excel => {
          const tHeader = ['姓名', '性别', '年龄', '联系电话', '身份证号', '主刀医生', '手术名称', '手术时间', '当前手术路径', '预约来源']
          const filterVal = ['name', 'gender', 'age', 'telephone', 'ID', 'doctor', 'surgery', 'expectTime', 'currentStep', 'origin']
          const list = this.tableList1
          const data = this.formatJson(filterVal, list)
          excel.export_json_to_excel({
            header: tHeader,
            data,
            filename: 'report',
            autoWidth: true
          })
        })
      },
      formatJson(filterVal, jsonData) {
        return jsonData.map(v => filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        }))
      },
      // 进入手术分页
      getListByPagination(listQuery) {
        this.listQuery = listQuery
        this.getTableList1(listQuery)
      },
      getTableList1(listQuery) {
        const query = Object.assign({}, listQuery, this.filter1)
        var data = {}
        data.current = query.page
        data.size = query.limit
        if (query != null) {
          var keyWord = query.keyWord === null || query.keyWord === '' ? null : query.keyWord
          if (query.type === 'type0') {
            data.patientName = keyWord
          } else if (query.type === 'type1') {
            data.phoneFour = keyWord
          } else {
            data.visitCard = keyWord
          }
          data.dateTime = query.today
          data.appointmentStatus = query.surgeryPath
        }
        patientList(data).then((res) => {
          this.tableList1 = res.data.list
          this.totalList1 = res.data.total
        })
      },
      // 获取历史病人分页数据
      getHisPatient(listQuery) {
        const query = Object.assign({}, listQuery, this.filter2)
        var data = {}
        data.current = query.page
        data.size = query.limit
        if (query != null) {
          var keyWord = query.keyWord === null || query.keyWord === '' ? null : query.keyWord
          if (query.type === 'type0') {
            data.patientName = keyWord
          } else if (query.type === 'type1') {
            data.phoneFour = keyWord
          } else {
            data.visitCard = keyWord
          }
        }
        getHisPage(data).then((res) => {
          this.tableList3 = res.data.list
          this.totalList2 = res.data.total
        })
      },
      getHisListByPagination(listQuery) {
        this.listQuery1 = listQuery
        this.getHisPatient(listQuery)
      },
      next() {
        console.log(this.dialogLeftTop1_1_step_active)
        if (this.dialogLeftTop1_1_step_active >= 3) {
          this.dialogLeftTop1_1 = false
        }
        if (this.dialogLeftTop1_1_step_active++ > 2) {
          this.dialogLeftTop1_1_step_active = 1
          this.nextText = '下一步'
        }
        if (this.dialogLeftTop1_1_step_active >= 3) {
          this.dialogLeftTop1_1_tab_active = '2'
          this.nextText = '完成'
          return
        } else {
          this.dialogLeftTop1_1_tab_active = this.dialogLeftTop1_1_step_active - 1 + ''
          // 手术报到更新
          if (this.dialogLeftTop1_1_step_active === 1) {
            var flag = this.dialogLeftTop1_1_tab1_data.rigistration === undefined || this.dialogLeftTop1_1_tab1_data.rigistration === null
            var reportTime = flag ? parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}') : this.dialogLeftTop1_1_tab1_data.rigistration
            var data = {
              'appointNo': this.selectArr[0].appointNo,
              'patientId': 1,
              'eduType': this.dialogLeftTop1_1_tab2_data.PAEType,
              'eduCode': this.dialogLeftTop1_1_tab2_data.PAEContent,
              'reportTime': reportTime,
              'createrId': 0
            }
            insertConfirmRecord(data).then((res) => {
              console.log(res.data)
              this.dialogLeftTop1_1_tab2_data.PAEType = ''
              this.dialogLeftTop1_1_tab2_data.PAEContent = ''
              this.getTableList1(this.listQuery)
            })
          }
        }
      }
    },
    computed: {
      disabled() {
        return this.selectArr.length > 0
      },
      disabled2() {
        return this.selectArr2.length > 0
      },
      disabled3() {
        return this.selectArr3.length > 0
      }
    },
    directives: {
      waves
    }
  }
</script>
<style lang="scss">
  .tabPanel{
    height: 100%;
    background-color: #fff;
    padding-top: 10px;
    overflow: auto;
    .el-tabs__header{
      padding-left: 20px;
    }
  }
  .filterBox{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .filterPart{
      line-height: 2;
    }
  }
  .dialogLeftTop1_1 .el-tabs__header {
    display: none !important;
  }
  .el-col{
    padding: 15px 0;
  }
  .tab1 .el-select{
    display: block;
  }
</style>
